#ifndef __MYPROTOCOL_H__
#define __MYPROTOCOL_H__

#include <pthread.h>
typedef long int64_t; // 8字节long
/* 用户登录信息 */
typedef struct _user_info
{
    char id[20];
    char pw[20];
    char flag; // 1: login, 0: logout
} user_info_t;
/* 链表节点 */
typedef struct _list
{
    int fd;
    pthread_t tid;
    char id[20];
    struct _list *next;
} list_t;
/* 环境信息 */
typedef struct _env_info
{
    float tem;
    float hum;
    float lx;
    unsigned char dev_state;
} env_info_t;
/* 阈值设定信息 */
typedef struct _threshold_info
{
    float tem_min;
    float hum_min;
    float lx_min;
    float tem_max;
    float hum_max;
    float lx_max;
} threshold_info_t;
/* 协议结构体 */
typedef struct _myprotocol
{
    // long msgtype;
    int64_t msgtype; 
    long uid;
    unsigned char auto_open;
    unsigned char cmd;
    user_info_t user_info;
    env_info_t env_info;
    threshold_info_t threshold_info;
    char control_data;
} myprotocol_t;
/* 消息队列type枚举 */
enum msgtype_t
{
    BOA_TO_SER_ISONLINE = 1,
    BOA_TO_SER_OP,
};
/* 发送枚举协议 */
enum sendprotocol_t
{
    ISONLINE_REQ = 0,
    GET_ENVVAL_REQ,
    SET_THRESHOLD_REQ,
    CONTROL_DEV_REQ,
    AUTO_CONTROL_CLOSE,
    AUTO_CONTROL_OPEN,
};
/* 接收枚举协议 */
enum recvprotocol_t
{
    ISONLINE_ACK = 50,
    GET_ENVVAL_ACK,
    SET_THRESHOLD_ACK,
    CONTROL_DEV_ACK,
};

#endif